package com.shop.test;

import java.math.BigDecimal;
import java.util.Date;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.shop.entity.Product;
import com.shop.util.HibernateUtil;

public class DeptDaoTest2 {
	private Session session;
	@Test
	public void test2ddl(){
		System.out.println("-------");
		BigDecimal b=new BigDecimal(9999.1276);
		Product p1 = new Product("小米电视",b, new Date(), false);
		Transaction tx = session.beginTransaction();
		session.save(p1);
		tx.commit();
	}
	
	
	
	@Before
	public void before(){
		//1.获取session对象
		session  =HibernateUtil.getSesssion();
	}
	@After
	public void after(){
		//5.关闭资源
		HibernateUtil.closeSession(session);
	}
	
	
}
